package Week2.J0427;

// 暴力for循环 超时
// 动态规划 三个状态转移方程

import java.util.Scanner;

public class mari和shiny_x {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        char[] arr = scanner.next().toCharArray();
        long s = 0; // s   的个数
        long h = 0; // sh  的个数
        long y = 0; // shy 的个数
        for (int i = 0; i < n; i++) {
            if (arr[i] == 's') s++;
            else if (arr[i] == 'h') h += s;
            else if (arr[i] == 'y') y += h;
        }
        System.out.println(y);
    }
}
